var pageNo = null;
var totalPage = 0;

$(function(){
	getInvestLogs();
	
	/* 分页页码  */
	if(totalPage == 0){
		$("#page").html('<tr><td colspan="9">暂无详情信息</td></tr>');
	}else{
		$("#page").Page({
			totalPages : totalPage,//分页总数
			liNums : 7,//分页的数字按钮数(建议取奇数)
			activeClass : 'activP', //active 类样式定义
		    hasFirstPage: true,//whether has first button
		    hasLastPage: true,//whether has last button
		    hasPrv: true,//whether has prev button
		    hasNext: true,//whether has next button
			callBack : function(page){
				pageNo = page;
				getInvestLogs();
			}
		});
	}
});

function getInvestLogs(){
	$.ajax({
		url:g_requestContextPath + "/invest/investBackList",
		type:"post",
		dataType:"json",
		data:{"pageNo":pageNo},
		async:false,
		success:function(result){
			totalPage = Math.ceil(result.totalRow / 5);
			var backStatus ={"Y":"已回款","N":"未回款"};
			var data = result.list;
			var logsHtml = '';
			for (var i = 0; i < data.length; i++) {
				logsHtml += '<tr>';
				logsHtml += '<td>'+data[i].backTime.substring(0,10)+'</td>';
				logsHtml += '<td>'+data[i].proTitle+'</td>';
				if(data[i].unit == 'month'){
					logsHtml += '<td>'+data[i].order+'/'+data[i].cycle+'期</td>';
				}else{
					logsHtml += '<td>'+data[i].order+'/1期</td>';
				}
				logsHtml += '<td>'+thousandBitSeparator(parseInt(data[i].backCapital/100))+'</td>';
				logsHtml += '<td>'+thousandBitSeparator(parseInt((data[i].backAmount-data[i].backCapital)/100))+'</td>';
				logsHtml += '<td>'+backStatus[data[i].status]+'</td>';
				logsHtml += '</tr>';
			}
			$("#investBackList").html(logsHtml);
		}
	});
}


